<?php

namespace Xsjosg\Zt\App\Webapp\Sixyear251014\Tests;

use Xsjosg\Zt\Core\Testing\TestCase;
use Xsjosg\Zt\App\Webapp\Sixyear251014\Providers\LogicServiceProvider;



class MainTest extends TestCase
{
    /**
     * 初始化方法，并创建app
     */
    public function setUp(): void
    {
        parent::setUp();
        app()->register(LogicServiceProvider::class);
    }

    public function testGetPlayerReviewDataFromApi()
    {
       $result = app('logic')->getPlayerReviewDataFromApi(41769482, 501);
       var_dump($result);
       $this->assertNotNull($result);
    }

    public function testGetShareRewardFromApi()
    {
       $result = app('logic')->getShareRewardFromApi(11560099, 501);
       var_dump($result);
       $this->assertNotNull($result);
    }

    public function testGetReviewRewardFromApi()
    {
       $result = app('logic')->getReviewRewardFromApi(11560099, 501);
       var_dump($result);
       $this->assertNotNull($result);
    }
    
    /**
     * @see Controller::loginBySdkAction()
     * @see LogicServiceProvider::loginBySdk()
     */
    public function testLoginBySdk()
    {
        $result = $this->createRequest([
            'uri' => '/webapp/sixyear251014/login_by_sdk',
            'parameters' => [
                'username' => 'U517273975A',
                'cuid' => '507273975',
                'token' => '501f683d-f1a7-3bfa-80af-b0f996054cc2',
            ],
        ])->run();
        $this->assertResponseSuccessAndGetData($result);
    }

    /**
     * @see Controller::loginKjqAction()
     * @see LogicServiceProvider::loginKjq()
     */
    public function testLoginKjq()
    {
        $result = $this->createRequest([
            'uri' => '/webapp/sixyear251014/login_kjq',
            'parameters' => [
                'token' => '',
            ],
        ])->run();
        $this->assertResponseSuccessAndGetData($result);
    }

    /**
     * @see Controller::loginByUidAction()
     * @see LogicServiceProvider::loginByUid()
     */
    public function testLoginByUid()
    {
        $result = $this->createRequest([
            'uri' => '/webapp/sixyear251014/login_by_uid',
            'parameters' => [
                'token' => 'xxxxxxx',
            ],
        ])->run();
        $this->assertResponseSuccessAndGetData($result);
    }

    /**
     * @see Controller::getServerListAction()
     * @see LogicServiceProvider::getServerList()
     */
    public function testGetServerList()
    {
        $result = $this->createRequest([
            'uri' => '/webapp/sixyear251014/get_server_list',
            'parameters' => [],
        ])->run();
        $this->assertResponseSuccessAndGetData($result);
    }

    /**
     * @see Controller::loginByServerIdAction()
     * @see LogicServiceProvider::loginByServerId()
     */
    public function testLoginByServerId()
    {
        $result = $this->createRequest([
            'uri' => '/webapp/sixyear251014/login_by_server_id',
            'parameters' => [
                'server_id' => '500',
            ],
        ])->run();
        $this->assertResponseSuccessAndGetData($result);
    }

    /**
     * @see Controller::loginByRoleIdAndServerIdAction()
     * @see LogicServiceProvider::loginByRoleIdAndServerId()
     */
    public function testLoginByRoleIdAndServerId()
    {
        $result = $this->createRequest([
            'uri' => '/webapp/sixyear251014/login_by_role_id_and_server_id',
            'parameters' => [
                'server_id' => '1000',
                'role_id' => '1000',
                'role_name' => 'test',
            ],
        ])->run();
        $this->assertResponseSuccessAndGetData($result);
    }

    /**
     * @see Controller::getCurrentUserAction()
     * @see LogicServiceProvider::getCurrentUser()
     */
    public function testGetCurrentUser()
    {
        $result = $this->createRequest([
            'uri' => '/webapp/sixyear251014/get_current_user',
            'parameters' => [],
        ])->run();
        $this->assertResponseSuccessAndGetData($result);
    }

    /**
     * @see Controller::loginOutAction()
     * @see LogicServiceProvider::loginOut()
     */
    public function testLoginOut()
    {
        $result = $this->createRequest([
            'uri' => '/webapp/sixyear251014/login_out',
            'parameters' => [],
        ])->run();
        $this->assertResponseSuccessAndGetData($result);
    }

    public function testGetUserConfig()
    {
        $result = $this->createRequest([
            'uri' => '/webapp/sixyear251014/get_user_config',
            'parameters' => [],
        ])->run();
        $this->assertResponseSuccessAndGetData($result);
    }

    /**
     * @see Controller::queryPlayerReviewDataAction()
     * @see LogicServiceProvider::queryPlayerReviewData()
     */
    public function testQueryPlayerReviewData()
    {
        $result = $this->createRequest([
            'uri' => '/webapp/sixyear251014/query_player_review_data',
            'parameters' => [
                'share_uid' => 'a5fb90d9e93f9eb8f6204b4a4134293f',
            ],
        ])->run();
        $this->assertResponseSuccessAndGetData($result);
    }
    
    /**
     * @see Controller::getReviewRewardAction()
     * @see LogicServiceProvider::getReviewReward()
     */
    public function testGetReviewReward()
    {
        $result = $this->createRequest([
            'uri' => '/webapp/sixyear251014/get_review_reward',
            'parameters' => [
            ],
        ])->run();
        $this->assertResponseSuccessAndGetData($result);
    }

    /**
     * @see Controller::getShareRewardAction()
     * @see LogicServiceProvider::getShareReward()
     */
    public function testGetShareReward()
    {
        $result = $this->createRequest([
            'uri' => '/webapp/sixyear251014/get_share_reward',
            'parameters' => [
            ],
        ])->run();
        $this->assertResponseSuccessAndGetData($result);
    }

    /**
     * @see Controller::getShareUidAction()
     * @see LogicServiceProvider::getShareUid()
     */
    public function testGetShareUid()
    {
        $result = $this->createRequest([
            'uri' => '/webapp/sixyear251014/get_share_uid',
            'parameters' => [
            ],
        ])->run();
        $this->assertResponseSuccessAndGetData($result);
    }

    /**
     * @see Controller::makeFinishShareAction()
     * @see LogicServiceProvider::makeFinishShare()
     */
    public function testMakeFinishShare()
    {
        $result = $this->createRequest([
            'uri' => '/webapp/sixyear251014/make_finish_share',
            'parameters' => [
            ],
        ])->run();
        $this->assertResponseSuccessAndGetData($result);
    }    

    /**
     * 清理工作
     */
    public function tearDown(): void
    {
        //如果需要清理,请去掉相关注释
        /*
        
        $redisInstance = $this->app['redis']->select('webapp');
        $keys = (array) $redisInstance->keys('webapp/fiveyear230911/*');
        foreach ($keys as $key) {
            $redisInstance->del($key);
        }
        */
        parent::tearDown();
    }
}
